extends Area2D


@onready var game_manager: Node = %GameManager
@onready var collision_shape: CollisionShape2D = $CollisionShape2D
@onready var animated_sprite: AnimatedSprite2D = $AnimatedSprite2D


func _on_body_entered(body: Node2D) -> void:  # 玩家碰到金币时，分数+1
	game_manager.add_point()  # 调用GameManager加分函数
	animated_sprite.queue_free()  # 销毁金币动画
	collision_shape.queue_free()  # 销毁金币碰撞体
	$PickupSound.play()  # 播放捡到金币音效
	$Timer.start()  # 开始倒计时0.2秒，等待音效播放完毕


func _on_timer_timeout() -> void:  # 倒计时结束摧毁金币节点
	queue_free()
